*------------------------------------------------------------------------------
* clean Wave 2 inhome data
*==============================================================================

* Biological Sex : bio_sex2
gen female = bio_sex2 == 2 if ~missing(bio_sex2)

* Same-school attendance
gen same_school = h2gi7
gen same_sschool = h2gi8

* Grade
gen grade = h2gi9 if h2gi9 != 98
replace grade = . if h2gi9 == 13 // beyond high school
replace grade = . if h2gi9 == 14 // school doesn't have grades of this kind

* No race information available

* Depressive Symptoms (depression)
gen dep_bother = h2fs1
gen dep_eating = h2fs2
gen dep_blues = h2fs3
gen dep_good_rev = 3-h2fs4
gen dep_keepmind = h2fs5
gen dep_depress = h2fs6
gen dep_tired = h2fs7
gen dep_hope_rev = 3-h2fs8
gen dep_failure = h2fs9
gen dep_fearful = h2fs10
gen dep_happy_rev = 3-h2fs11
gen dep_enjoy_rev = 3-h2fs15
gen dep_sad = h2fs16
gen dep_start = h2fs18
gen dep_life = h2fs19

sum dep_*
alpha dep_*
for var dep_*: replace X = . if X == -3 | X == 6

egen cesd = rowtotal(dep_*) 

gen dep_talkless = h2fs12 
gen dep_lonley = h2fs13 
gen dep_unfriend = h2fs14 
gen dep_dislike = h2fs17 

for var dep_*: replace X = . if X == -3 | X == 6

egen fcesd = rowtotal(dep_*) 

for var dep_*: replace cesd = . if missing(X)
for var dep_*: replace fcesd = . if missing(X)

drop h2gi1m-h2ir31
foreach X of varlist * {
	if "`X'" != "aid" {
	rename `X' `X'_2
	}
}



